home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / util / pack / xpk_Source.lha / xpk_Source / test / testNILPack.c < prev    next >
C/C++ Source or Header  |  1998-02-08  |  2KB  |  107 lines

  1. #define NAME        "testNILPack"
  2. #define DISTRIBUTION    "(Freeware) "
  3. #define REVISION    "1"
  4.  
  5. /* Programmheader
  6.  
  7.     Name:        testNILPack
  8.     Author:        SDI
  9.     Distribution:    Freeware
  10.     Description:    tests Xpk with NIL argument function
  11.     Compileropts:    -
  12.     Linkeropts:    -l xpkmaster amiga
  13.  
  14.  1.0   01.04.97 : first version
  15.  1.1   28.11.97 : moved chunk-hook into include file
  16. */
  17.  
  18. #include <proto/dos.h>
  19. #include <proto/xpkmaster.h>
  20. #include <proto/exec.h>
  21. #include "SDI_defines.h"
  22. #include "chunkfunc.c"
  23.  
  24. struct Library *XpkBase;
  25.  
  26. void main(int argc, char **argv)
  27. {
  28.   STRPTR obuf = 0;
  29.   ULONG fh, err, obuflen = 0, olen = 0;
  30.  
  31.   if(argc != 2)
  32.   {
  33.     VPrintf("Filename needed\n", 0);
  34.     exit(0);
  35.   }
  36.  
  37.   if(!(XpkBase = OpenLibrary("xpkmaster.library", 4)))
  38.     exit(10);
  39.  
  40.   if(!(fh = Open("NIL:", MODE_NEWFILE)))
  41.   {
  42.     VPrintf("Could not open fh\n", 0);
  43.     CloseLibrary(XpkBase);
  44.     exit(10);
  45.   }
  46.  
  47.   VPrintf("Testing FH Pack access\n", 0);
  48.  
  49.   if((err = XpkPackTags(
  50.     XPK_InName,    argv[1],
  51.     XPK_OutFH,    fh,
  52.     XPK_ChunkHook,    &chunkhook,
  53.     XPK_PackMethod,    "NUKE",
  54.     TAG_DONE)))
  55.     XpkPrintFault(err, "FH Pack try");
  56.  
  57.   VPrintf("Testing Name Pack access\n", 0);
  58.  
  59.   if((err = XpkPackTags(
  60.     XPK_InName,    argv[1],
  61.     XPK_OutName,    "NIL:",
  62.     XPK_ChunkHook,    &chunkhook,
  63.     XPK_PackMethod,    "NUKE",
  64.     TAG_DONE)))
  65.     XpkPrintFault(err, "Name Pack try");
  66.  
  67.   VPrintf("Producing packed file\n", 0);
  68.  
  69.   if((err = XpkPackTags(
  70.     XPK_InName,        argv[1],
  71.     XPK_PackMethod,        "NUKE",
  72.     XPK_GetOutBuf,        &obuf,
  73.     XPK_GetOutBufLen,     &obuflen,
  74.     XPK_GetOutLen,         &olen,
  75.     XPK_ChunkHook,        &chunkhook,
  76.     TAG_DONE)))
  77.     XpkPrintFault(err, "Normal Pack try");
  78.  
  79.   VPrintf("Testing FH Unpack access\n", 0);
  80.  
  81.   if((err = XpkUnpackTags(
  82.     XPK_InBuf,    obuf,
  83.     XPK_InLen,    olen,
  84.     XPK_OutFH,    fh,
  85.     XPK_ChunkHook,    &chunkhook,
  86.     TAG_DONE)))
  87.     XpkPrintFault(err, "FH Unpack try");
  88.  
  89.   VPrintf("Testing direct Unpack access\n", 0);
  90.  
  91.   if((err = XpkUnpackTags(
  92.     XPK_InBuf,    obuf,
  93.     XPK_InLen,    olen,
  94.     XPK_OutName,    "NIL:",
  95.     XPK_ChunkHook,    &chunkhook,
  96.     TAG_DONE)))
  97.     XpkPrintFault(err, "Name Unpack try");
  98.  
  99.   if(obuf)
  100.     FreeMem(obuf, obuflen);
  101.  
  102.   if(!Close(fh))
  103.     VPrintf("Could not close fh\n", 0);
  104.   CloseLibrary(XpkBase);
  105. }
  106.  
  107.